<template>
  <div class="home-page">
    <el-card class="welcome-card">
      <h1>欢迎使用惊喜一餐！</h1>
    </el-card>
    <el-input placeholder="搜索餐厅" class="search-input"></el-input>
    <div class="recommend-restaurants">
      <el-card class="restaurant-card" v-for="restaurant in recommendedRestaurants" :key="restaurant.id">
        <img :src="restaurant.image" alt="" class="restaurant-image">
        <div class="restaurant-info">
          <h3>{{ restaurant.name }}</h3>
          <el-rate v-model="restaurant.rating"></el-rate>
          <el-button type="primary" @click="goToDetails(restaurant.id)">查看详情</el-button>
        </div>
      </el-card>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      recommendedRestaurants: [
        { id: 1, name: '餐厅A', image: require('@/assets/img.png'), rating: 4.5 },
        // 更多餐厅...
      ]
    };
  },
  methods: {
    goToDetails(id) {
      this.$router.push(`/restaurant-details/${id}`);
    }
  }
};
</script>

<style>
.home-page {
  padding: 20px;
}
.welcome-card {
  margin-bottom: 20px;
}
.search-input {
  margin-bottom: 20px;
}
.recommend-restaurants {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}
.restaurant-card {
  width: calc(25% - 10px);
}
.restaurant-image {
  width: 100%;
  height: 150px;
  object-fit: cover;
}
.restaurant-info {
  padding: 10px;
}
</style>
